package com.cj.http;

import com.cj.models.ResultModel;
import org.apache.tomcat.util.bcel.classfile.ClassFormatException;
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@ControllerAdvice
public class ExcepHandler {

    @ResponseBody
    @ExceptionHandler(Exception.class)
    public ResultModel handler(Exception e){
        return new ResultModel("error",e.getMessage()+" "+e.getClass().getName());
    }

    @ResponseBody
    @ExceptionHandler(NoSuchBeanDefinitionException.class)
    public ResultModel NoSuchBeanDefinitionException_Handler(Exception e){
        return new ResultModel("error","no service");
    }





}
